#include<iostream>
#include<algorithm> 
using namespace std;
struct Student{
	char id[10];
	char name[50];
	int a;
	int b;
	int c;
};
bool cmp(Student s1,Student s2){
	return s1.a+s1.b+s1.c>s2.a+s2.b+s2.c;
}
Student s[100];
int main(){
	int n,a_avg=0,b_avg=0,c_avg=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s%s%d%d%d",&s[i].id,&s[i].name,&s[i].a,&s[i].b,&s[i].c);
		a_avg+=s[i].a;
		b_avg+=s[i].b;
		c_avg+=s[i].c;
	}
	a_avg/=n;
	b_avg/=n;
	c_avg/=n;
	sort(s,s+n,cmp);
	printf("%d %d %d\n",a_avg,b_avg,c_avg);
	printf("%s %s %d %d %d\n",s[0].id,s[0].name,s[0].a,s[0].b,s[0].c);
	return 0;
} 
